﻿@model Matrix.MaKaYunShang.Model.SysMoney
    @{
        ViewBag.Title = "系统金额设置";
        ViewBag.PathToBtn = "/SysConfig/SysMoney";
        ViewBag.TextBtn = "刷新";
        Layout = "~/Views/Shared/_Layout.cshtml";
    }

    <div class="row">
        <div class="col-lg-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    系统金额设置
                </div>
                <div class="panel-body">
                    <div class="row">
                        @using (Html.BeginForm("SysMoney", "SysConfig", FormMethod.Post, new { id = "frmCreate", enctype = "multipart/form-data" }))
                        {
                            @Html.AntiForgeryToken()
                            @Html.ValidationSummary(true)

                            <div class="col-lg-12">
                                <fieldset>

                                    <div class="form-group col-md-6">
                                        <label>当前平台账面值</label>
                                        @Html.TextBoxFor(model => model.CurrentCash, new { @class = "form-control", placeholder = "当前平台账面值" })
                                    </div>
                                    
                                    <div class="form-group col-md-6">
                                        <label>派送红包已发送总额</label>
                                        @Html.TextBoxFor(model => model.TotalDeliveryRedEnvolope, new { @class = "form-control", placeholder = "派送红包已发送总额", @disabled = true })
                                    </div>
                                    <div class="form-group col-md-6">
                                        <label>分享红包已发送总额</label>
                                        @Html.TextBoxFor(model => model.TotalShareRedEnvolope, new { @class = "form-control", placeholder = "分享红包已发送总额", @disabled = true })
                                    </div>
                                    <div class="form-group col-md-6">
                                        <label>订单立减总金额</label>
                                        @Html.TextBoxFor(model => model.CurrentCash, new { @class = "form-control", placeholder = "订单立减总金额", @disabled = true })
                                    </div>
                                 
                                    <div class="col-md-12">
                                        <button type="button" class="btn btn-primary" id="btnSave">保存设置</button>
                                    </div>
                                </fieldset>
                            </div>
                        }
                    </div>
                </div>
            </div>
        </div>
    </div>

    @section javascript{
        <script type="text/javascript">
            $(function () {
                $("#frmCreate").validate({
                    rules: {
                        CurrentCash: { required: true, min: 0, number: true }
                    },
                    messages: {
                        CurrentCash: { required: "当前平台账面值" },

                    }
                });

                $("#btnSave").click(function () {
                    if ($("#frmCreate").valid()) {

                        $.ajax({
                            type: 'post',
                            url: '@Url.Action("SysMoney")',
                            data: $("#frmCreate").serialize(),
                            success: function (data) {
                                if (data.Status) {
                                    alertify.success("保存成功");
                                } else {
                                    alertify.error(data.Message);
                                }
                            },
                            error: function () {
                                alertify.error("保存失败，请重试！");
                            }
                        });
                    }
                });


            });


        </script>
    }